package com.ezops.poc.bo;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import javax.annotation.PostConstruct;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import com.ezops.poc.dao.UtilityDAO;

/**
 * Client Entity
 * 
 * @author vgaurav
 * 
 */
@Component
public class ClientLookUp {

	@Autowired
	private UtilityDAO dao;

	private static Map<String, Integer> mapping = null;

	public static int lookUp(String key) {
		return mapping.get(key);
	}

	@PostConstruct
	public void load() {
		mapping = new HashMap<>();
		List<Client> clients = dao.getAllClients();
		for (Client client : clients) {
			mapping.put(client.getClientName(), client.getClientId());
		}
	}
}
